{% extends 'main.html' %}
{% load i18n %}

{% block comments %}
<div class="comment">
	  <h3>{% trans 'Recent Comments' %}:</h3>
	  
	{% for comment in fileComments %}
	  <p>
	  <strong>{{comment.name|escape}}:</strong><a href="/main/file/?id={{comment.mfile.key.id}}">{{comment.content|escape}}</a>
	  </p>
	{% endfor %}
</div>
{% endblock comments %}

{% block message%}
{% endblock message%}

{% block content %}
  <div id="detail">
    <h3>
        {% trans 'Categories' %}:&nbsp;&nbsp;
              <a href="/main/downloads/">
              {% trans 'All' %}
              </a>
          
        {% for category in categories %}
                  &nbsp;&nbsp;
                  <a href="/main/downloads/?category={{category.key.id}}"  title="{{category.describe}}">
                  {{category.name}}
                  </a>({{category.file_set.count}})
        {% endfor %}
    </h3>
    {% for file in data %}
        <div class="post">
            <h1>
                <a href="/main/file/?id={{file.key.id}}">
                      {{file.name}}
                    </a>
            </h1>
            <h5>
                {{file.createTime|date:"Y-m-d H:i:s"}}&nbsp;&nbsp;
                {% trans "Category" %}:<a href="/main/downloads/?category={{file.jumCategory.key.id}}">{{file.jumCategory.name}}</a>&nbsp;&nbsp;
                {% trans "Comments" %}:{{file.filecomment_set.count}}&nbsp;&nbsp;
            </h5>

            <p>{{file.describe}}</p> 
            <h4>
                <a href="/main/download/?id={{file.key.id}}" target="_blank">
                          {% trans 'Download' %}
                        </a>
            </h4>
        </div>
    {% endfor %}
    	{% if page and page.has_other_pages %}
    	<div class="pagination">
    		<h3>
    			{% if page.has_previous %}
    				<a href="/main/downloads/?page={{page.previous_page_number}}">{% trans "Previous" %}</a>
    			{% else %}
    				{% trans "Previous" %}
    			{% endif %}
    			&nbsp;&nbsp;
    			{% if page.has_next %}
    				<a href="/main/downloads/?page={{page.next_page_number}}">{% trans "Next" %}</a>
    			{% else %}
    				{% trans "Next" %}
    			{% endif %}
    			&nbsp;&nbsp;&nbsp;&nbsp;
    			{{ page.number }}&nbsp;of&nbsp;{{ page.paginator.num_pages }}
    		</h3>
    	</div>
    	{% endif %}
    </div>
{% endblock content %}